import request from "@/util/http";
import qs from "qs";

export default {
  //获取接口数据渲染页面
  gain(forms) {
    return request({
      method: "get",
      params: {
        _gp: "admin.role",
        _mt: "list",
        name: forms.input,
        page: forms.pageNo,
        limit: forms.pageSize
      }
    });
  },
  //添加角色
  adduser(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.role",
        _mt: "create",
        role: JSON.stringify(form)
      })
    });
  },
  //编辑角色
  compile(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.role",
        _mt: "update",
        role: JSON.stringify(form)
      })
    });
  },
  //删除接口
  cancel(id) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.role",
        _mt: "delete",
        roleId: id
      })
    });
  },
  //修改权限
  Authoriza(roleId, permissions) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.role",
        _mt: "permissionSet",
        roleSetPermissionDTO: JSON.stringify({
          roleId: roleId,
          permissions: permissions
        })
      })
    });
  },
  //获取权限
  authorization(roleId) {
    return request({
      method: "get",
      params: {
        _gp: "admin.role",
        _mt: "permissionList",
        roleId: roleId
      }
    });
  }
};
